<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/page.js"></script>
<title>活动分类管理</title>
</head>
<body>
	<jsp:include page="navigation.jsp"></jsp:include>
	<div class="container" style="margin-left: 190px; margin-bottom: 25px;">
		<div class="topbar-inner">
			<div class="myhead">
				<span class="crumb-name">活动分类管理</span>
			</div>
		</div>
		<div class="topbar-inner">
			<div class="search">
				<div class="input-group">
					<button type="button" id="add_btn" onclick="editor('')" class="btn btn-default" style="margin-left: 20px; margin-top: 1px;">新增</button>
				</div>
			</div>
		</div>
		<form id="pageForm" action="eventtypeinfo" method="post">
			<c:if test="${ page != null }">
				<input type="hidden" value="${ page.pageCount }" id="pageCount" name="pageCount" />
				<input type="hidden" value="${ page.pageIndex }" id="pageIndex" name="pageIndex" />
			</c:if>
		</form>

		<div style="margin: 20px 20px 20px 20px; text-align: center;">
			<table class="table table-bordered table-hover table-striped">
				<thead>
					<tr>
						<th>类别</th>
						<th>标题</th>
						<th>简介</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${ list }" var="l">
						<tr>
							<td>${ l.type_name }</td>
							<td>${ l.title_json }</td>
							<td>${ l.intro_json }</td>
							<td width="12%"><a href="javascript:" onclick="editor(${ l.id })">修改</a> &emsp;|&emsp; <a href="javascript:" onclick="deleteType(${ l.id })">删除</a></td>
						</tr>
					</c:forEach>

				</tbody>
			</table>
			<c:if test="${ page == null }">
				<div style="font-size: larger;">暂无数据</div>
			</c:if>
			<c:if test="${ page != null && page.pageCount > 1 }">
				<ul id="pagination" class="pagination">

				</ul>
				<script type="text/javascript">
					setPage(document.getElementById("pagination"), parseInt($(
							"#pageCount").val()), parseInt($("#pageIndex")
							.val()));
				</script>
			</c:if>
		</div>
	</div>
	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<form action="" id="modal_form" method="post">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title" id="myModalLabel">类别管理</h4>
					</div>
					<div class="modal-body">
						<input type="hidden" id="modal_id" class="form-control" name="id" />
						<div style="width: 100%; height: 40px;">
							类别名称：<input type="text" id="modal_type_name" class="form-control" name="type_name" />
						</div>
						<div style="width: 100%; height: 40px;">
							标&emsp;&emsp;题：<input type="text" id="modal_title_json" class="form-control" name="title_json" />
						</div>
						<div style="width: 100%; height: 40px;">
							简&emsp;&emsp;介：<input type="text" id="modal_intro_json" class="form-control" name="intro_json" />
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button type="button" class="btn btn-primary" onclick="submitForm()">提交</button>
					</div>
				</form>
			</div>
		</div>
	</div>
	<!-- /.modal -->
	<script type="text/javascript">
    $(function() {
        $('.submenu_1_2').addClass('submenu_native');
    });

    function toEdit() {
        var event_id = $('input[name=event_id]').val();
    }

    function update(id,type_name,title_json,intro_json) {
        $("#modal_id").val(id);
        $("#modal_type_name").val(type_name);
        $("#modal_title_json").val(title_json); 
        $("#modal_intro_json").val(intro_json);
        $("#myModal").modal('show');
    }
    
    function editor(id){
        window.location.href = "./editorEventType?id="+id
    }

    function deleteType(id) {
        if(confirm("是否删除")){
            $.ajax({
                type: "post",
                url: "delete_eventtype",
                data: {id :id},
                success: function(data){
                    if (data != null) {
                        if(data.code == 0){
                            alert("删除成功");
                            window.location.reload();
                        }else{
                            alert("删除失败");
                            return;
                        }
                    }
                    
                }
            });
        }
    }
</script>
</body>
</html>